package com.java.base.io.netty;

import com.java.base.io.enter.ConsoleColorFont;

import java.time.LocalTime;

public class MsgRender {

    public static void main(String[] args) {
        String ms = MsgRender.msg("/127.0.0.1:52451", "上线，当前人数 " + (1));
        if (ms.substring(36).startsWith("/127.0.0.1:52451")) {

            char[] cs = ms.toCharArray();
            for (int i = 0; i < cs.length; i++) {
                System.out.println(i + " " + cs[i]);
            }

        }
        System.out.println(ms.substring(0, 32) + 2 + ms.substring(33));

//        System.out.println(ConsoleColorFont.render(ms.substring(31, 58), 0, 2, null));

    }

    public static StringBuilder header(String user) {
        StringBuilder userSb = new StringBuilder();
        userSb.append("[ ").append(user).append(" ]");
        userSb = ConsoleColorFont.render(userSb, 3, 3, null);

        StringBuilder timeSb = new StringBuilder("[ ").append(LocalTime.now().toString().substring(0, 8)).append(" ]");
        ConsoleColorFont.render(timeSb, 7, 0, 7);

        return timeSb.append(" ").append(userSb).append(" > ");

    }


    public static String msg(String user, String msg) {
        StringBuilder sb = header(user).append(ConsoleColorFont.renders(msg, 1, 5, null));

        return sb.toString();

    }


}
